package com.hunray.rent.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
@Entity
@Table(name="t_back")
public class Back implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Integer id;
	
	private String no;
	
	private String remark;//备注
	
	private User backer;
	
	private User receiver;
	
	private Date backDate;
	
	private ReturnMode returnMode;//如数归还，部分补偿，全额补偿
	
	private Double compensation;//赔偿金额
	
	private List<DeviceBack> deviceBacks;
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_back")
	@TableGenerator(name = "tg_back", table = "t_id", pkColumnName = "f_table", pkColumnValue = "t_back", valueColumnName = "f_id", allocationSize = 1, initialValue = 1)
	@Column(name = "f_id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="f_no",nullable=false,unique=true)
	@NotNull
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}
	@Column(name="f_remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Column(name="f_backer")
	public User getBacker() {
		return backer;
	}

	public void setBacker(User backer) {
		this.backer = backer;
	}
	@Column(name="f_receiver")
	public User getReceiver() {
		return receiver;
	}

	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}
	@Temporal(TemporalType.DATE)
	@Column(name="f_back_date")
	public Date getBackDate() {
		return backDate;
	}

	public void setBackDate(Date backDate) {
		this.backDate = backDate;
	}
	@Enumerated(EnumType.STRING)
	@Column(name="f_return_Mode")
	public ReturnMode getReturnMode() {
		return returnMode;
	}

	public void setReturnMode(ReturnMode returnMode) {
		this.returnMode = returnMode;
	}
	
	
	@Column(name="f_compensation")
	public Double getCompensation() {
		return compensation;
	}

	public void setCompensation(Double compensation) {
		this.compensation = compensation;
	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="back")
	public List<DeviceBack> getDeviceBacks() {
		return deviceBacks;
	}

	public void setDeviceBacks(List<DeviceBack> deviceBacks) {
		this.deviceBacks = deviceBacks;
	}
	
	
	

}
